package gframework.bean.internalFrame;

import gframework.bean.consultaCampo.GConsultaCampo;
import gframework.bean.mdiFrame.GMdiFrame;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class GInternalFrame extends javax.swing.JInternalFrame {

    protected GMdiFrame mdiFrame = null;
    protected GConsultaCampo consultaCampo = null;

    public GInternalFrame(GMdiFrame i_mdiFrame) throws Exception{
        initComponents();

        this.setClosable(true);
        this.setBackground(new Color(240, 240, 240));
        //this.setIconifiable(true);

        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        SwingUtilities.updateComponentTreeUI(this);

        mdiFrame = i_mdiFrame;
        mdiFrame.desktopPane.add(this);

        Dimension ds = mdiFrame.desktopPane.getSize();
        Dimension dw = this.getSize();

        setLocation((ds.width - dw.width) / 4, (ds.height - dw.height) / 5);
    }

    public void center() throws Exception {
//        if(this.getClass().getName().contains("Consulta") || this.getClass().getName().contains("Historico")){
//            this.setSize(750, 450);
//        }

        Dimension ds = mdiFrame.desktopPane.getSize();
        Dimension dw = this.getSize();

        setLocation((ds.width - dw.width) / 2, (ds.height - dw.height) / 3);
    }

    public void maximize() throws Exception {
//        ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
//        setBorder(null);

        this.setMaximum(true);
    }

    protected void setDefaultCursor() {
        this.setCursor(Cursor.getDefaultCursor());
    }

    protected void setWaitCursor() {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }

    public void setConsultaCampo(GConsultaCampo i_consultaCampo) {
        consultaCampo = i_consultaCampo;
    }
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBackground(new java.awt.Color(240, 240, 240));
        setClosable(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 394, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 302, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents



    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
